<div class='head'>$lang.get('accesslog.title')</div>

<div class='notes'>
	$!lang.get('accesslog.notes')
</div>

#parse('/widget/widget.message.html')

<div class='tabs'>
	<a href='/admin/accesslog' class='selected'>$lang.get('a.accesslog')</a>
</div>

<div class='search'>
	<form action='/admin/accesslog' method='get' class='form'>
		<span><label><h3>URI</h3>:<input type='text' name='guri' value="$!guri" /></label></span>
		<span><label><h3>SID</h3>:<input type='text' name='gsid' value="$!gsid" /></label></span>
		<span><label><h3>IP</h3>:<input type='text' name='ip' value="$!ip" /></label></span>
	
		<span class='line'></span>
		<span><label><h3>$lang.get('sort.by'):</h3>
			<select name='sortby'>
				<option value='created' #if($sortby == 'created') selected #end>Created</option>
				<option value='cost' #if($sortby == 'cost') selected #end>Cost</option>
			</select>
			<select name='sortby_type'>
				<option value='-1' #if($sortby_type == -1) selected #end>Down</option>
				<option value='1' #if($sortby_type == 1) selected #end>Up</option>
			</select></label></span>
	
		<button type='submit' class='btns1 icon icon-search'></button>
	</form>
	<div class='s1tab #if($currentpage>0) down #else up #end'>
		<div class='arrow'></div>
	</div>
</div>

<table id='accesslog-table' class='tablesorter nospace' border="0" cellpadding="0" cellspacing="1">
	<thead>
		<tr>
			<th>URL</th>
			<th>Module</th>
			<th>Model</th>
			<th>Method</th>
			<th>Status</th>
			<th>Cost(ms)</th>
			<th>SID</th>
			<th>UID</th>
			<th>USERNAME</th>
			<th>IP</th>
			<th>Created</th>
			<th style='width:15%;'>Client</th>
		</tr>
	</thead>
	<tbody>
#foreach($f in $list)
	<tr>
		<td>$!f.url</td>
		<td>$!f.module</td>
		<td>$!f.model</td>
		<td>$!f.method</td>
		<td>$!f.status</td>
		<td>$!f.cost</td>
		<td>$!f.sid</td>
		<td>$!f.uid</td>
		<td>$!f.username</td>
		<td>$!f.ip</td>
		<td>$lang.format($!f.created, 'yyyy-MM-dd HH:mm')</td>
		<td>$!f.client</td>
	</tr>
#end
	</tbody>
</table>

 #parse('/widget/goto.page.html')

#if($me.hasAccess('access.config.admin'))
<div class='btns'>
	<a href='javascript:;' class='btn btn-danger' onclick='_deleteall();'>$lang.get('a.clean')</a>
	&nbsp;&nbsp;
	<a href='javascript:;' class='closebtn btn btn-warning' style="display:none" onclick='_open(0);'>$lang.get('a.accesslog.disable')</a>
	<a href='javascript:;' class='openbtn btn btn-success' style="display:none" onclick='_open(1);'>$lang.get('a.accesslog.enable')</a>
</div>
#end

<script>
$('#accesslog-table').tablesorter();
$(function(){
	#if($global.getInt('accesslog.on', 1) == 1)
		$('a.closebtn').show();
		$('a.openbtn').hide();
	#else
		$('a.closebtn').hide();
		$('a.openbtn').show();
	#end	
})

function _open(on) {
	$.post('/admin/accesslog/open', {on:on}, function(d){
		if(d.state == 200) {
			if(d.on == 1) {
				$('a.closebtn').show();
				$('a.openbtn').hide();
				$.warn("$lang.get('accesslog.on')");
			} else {
				$('a.closebtn').hide();
				$('a.openbtn').show();
				$.warn("$lang.get('accesslog.off')");
			}
		}
	})
}

function _deleteall() {
	if(confirm("$lang.get('title.are_u_sure_delete')")) {
		processing && processing.show();
		$.post('/admin/accesslog/deleteall', {}, function(d) {
			processing && processing.hide();
			reload();
		});
	}
}
</script>
